const api = {
	baseUrlData: "https://apis.netstart.cn/maoyan"
}


// 视频列表数据
export const getVedioNavList = async (page, id) => await uni.request({
	url: `${api.baseUrlData}/video/${page}?feedChannelId=${id}`,
	method: "GET"
})

// 小视频列表数据
export const getVedioLittleList = async (page) => await uni.request({
	url: `${api.baseUrlData}/video/short/${page}`,
	method: "GET"
})

//获取城市列表
export const getCityList = async () => await uni.request({
	url: `${api.baseUrlData}/cities.json`,
	method: "GET"
});
export const getCity = async () => await uni.request({
	url: `${api.baseUrlData}/city/latlng?lat=23.4&lng=113.3`,
	method: "GET"
});
//获取当前最受好评电影
export const getTopRatedMovies = async (cityId = 0) => await uni.request({
	url: `${api.baseUrlData}/maoyan/index/topRatedMovies?ci=${cityId}`,
	method: "GET"
});
//获取当前热映电影
export const getMovieOnInfoList = async (cityId = 0, movieIds = []) => {
	let url = `${api.baseUrlData}/maoyan/index/`;
	if (movieIds.length) {
		let str = movieIds.join(",");
		url += `moreComingList?movieIds=${str}&ci=${cityId}`;
		console.log(url);
	} else {
		url += "movieOnInfoList?&ci=${cityId}";
	}
	return await uni.request({
		url,
		method: "GET"
	});
}
//获取待映近期最受期待电影
export const getMostExpected = async (cityId = 0) => await uni.request({
	url: `${api.baseUrlData}/maoyan/index/mostExpected?ci=${cityId}&limit=10&offset=0`,
	method: "GET"
});
//获取待映列表
export const getComingList = async (cityId = 0, movieIds = []) => {
	let url = `${api.baseUrlData}/maoyan/index`;
	if (!movieIds?.length) {
		url += `/comingList?ci=${cityId}&limit=10`;
	} else {
		let str = movieIds.join(",");
		url += `/moreComingList?ci=${cityId}&limit=10&movieIds=${str}`;
	}
	return await uni.request({
		url,
		method: "GET"
	});
}
//获取经典电影列表
export const getMoreClassicList = async (offset = 0) => await uni.request({
	url: `${api.baseUrlData}/maoyan/index/moreClassicList?sortId=1&showType=3&limit=10&offset=${offset}`,
	method: "GET"
});
//获取影院筛选条件
export const getFilterCinemas = async (cityId = 0) => await uni.request({
	url: `${api.baseUrlData}/maoyan/index/filterCinemas?ci=${cityId}`,
	method: "GET"
});
//获取影片上映时间
export const getMovieTime = async (movieId,cityId)=>{
	console.log(`${api.baseUrlData}/maoyan/movie/showdays?movieId=${movieId}&cityId=${cityId}`);
	return await uni.request({
		url:`${api.baseUrlData}/maoyan/movie/showdays?movieId=${movieId}&cityId=${cityId}`,
		method:"GET"
	})
};
//获取影院列表
export const getCinemaList = async (options) => {
	let allDate = '';
	let temp = new Date();
	let years = temp.getFullYear();
	let month = temp.getMonth() + 1;
	month = month >= 10 ? month : "0" + month;
	let date = temp.getDate();
	date = date >= 10 ? date : "0" + date;
	allDate = `${years}-${month}-${date}`;
	return await uni.request({
		url: `${api.baseUrlData}/maoyan/index/moreCinemas?day=${allDate}&offset=${options.offset}&limit=20&districtId=-1&lineId=-1&hallType=-1&brandId=-1&serviceId=-1&areaId=-1&stationId=-1&item&updateShowDay=true&reqId=1636710166221&cityId=${options.cityId}&lat=${options.latitude}&lng=${options.longitude}`,
		method: "GET"
	});
};
//获取电影详情
export const getMovieDetail = async (movieId) => await uni.request({
	url: `${api.baseUrlData}/maoyan/movie/detail?movieId=${movieId}`,
	method: "GET"
});
//获取影院上映条件筛选
export const getMovieSelect = async (options) => await uni.request({
	url:`${api.baseUrlData}/maoyan/movie/select/items?movieid=${options.movieId}&cityId=${options.cityId}&showDate=${options.date}`,
	method:"GET"
});
//获取筛选影院
export const getSelectCinema = async (options)=>{
	return await uni.request({
		url:`${api.baseUrlData}/maoyan/movie/select/cinemas?limit=20&offset=0&client=iphone&channelId=4&showDate=${options.date}&movieId=${options.movieId}&sort=distance&cityId=${options.cityId}&lat=${options.latitude}&lng=${options.longitude}&districtId=-1&lineId=-1&areaId=-1&stationId=-1&brandIds=%5B-1%5D&serviceIds=%5B-1%5D&hallTypeIds=%5B%22all%22%5D&languageIds=%5B%22all%22%5D&dimIds=%5B%22all%22%5D`,
		method:"GET"
	})
}
//获取影院详情
export const getCinemaDetail = async (options)=>{
	return await uni.request({
		url:`${api.baseUrlData}/maoyan/cinema/detail?cinemaId=${options.cinemaId}`,
		method:"GET"
	})
}